/* -----------------------------------------------------------------------
   See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
   ----------------------------------------------------------------------- */
#include "proj_image.h"
#include "proj_image_set.h"
#include "stdio.h"
#include "string.h"
#include "volume.h"

void CB_Set_clone(CB_Set * PSc, CB_Set * PSd)
{


	PSc->nproj=PSd->nproj;
	for(int i=0; i<PSc->nproj; i++){
		PSc->cbi[i]=proj_image_create ();
		proj_image_create_pmat(PSc->cbi[i]);
		proj_image_create_img(PSc->cbi[i],PSd->cbi[i]->dim);
		memcpy(PSc->cbi[i]->pmat,PSd->cbi[i]->pmat,sizeof(*(PSd->cbi[i]->pmat)));
		memcpy(PSc->cbi[i]->img,PSd->cbi[i]->img,sizeof(float)*PSd->cbi[i]->dim[0]*PSd->cbi[i]->dim[1]);
		}
	return;
}

double CB_Set_Prod(CB_Set * PSc, CB_Set * PSd)
{

	double sum=0;
	for(int i=0; i<PSc->nproj; i++)
		for( int p=0; p<PSc->cbi[i]->dim[0]*PSc->cbi[i]->dim[1]; p++)
			sum+=PSc->cbi[i]->img[p];
	return sum;
}

double Volume_Prod(Volume *V1, Volume *V2)
{
	double sum=0;
	for(int i=0; i<V1->npix; i++)
		sum+=((float *)V1->img)[i]*((float *)V2->img)[i];
	return sum;

}


